import { handleActions } from 'redux-actions';
import immutable from 'seamless-immutable';
import { generateUUID } from '../utils/utils';

// 初始state
const user_info = wx.getStorageSync('user_info') || {
  deviceid: generateUUID(),
};
export const INITIAL_STATE = immutable(user_info);

export default handleActions({
  'user/wechatLoginSuccess': (state, action) => {
  	state = state.merge(action.payload);
  	wx.setStorageSync('user_info', state);
  	return state;
  }
}, INITIAL_STATE);
